function loadData() {
    let pagenum = 0;
    let pagesize =3;
    let url = 'http://jx.xuzhixiang.top/ap/api/allproductlist.php';
    let uid = localStorage.getItem('uid');
    let token = localStorage.getItem('token');
    axios.get(url, {
        params: {
            pagenum,
            pagesize,
            uid
        }
    }).then(res => {
        console.log(res.data.data);             
        let arr = res.data.data;
        let html ='';
      
        arr.forEach(obj => {
            html += ` <li class="xq_list">
            <div class="img_box">          
                     <p><img src="${obj.pimg}" alt="" ></p>
                     </div>
                    <a href="xq.html?id=${obj.pid}"><p>${obj.pname}</p></a>
                    
                    <p>${obj.pdesc}</p>
                    <p>￥${obj.pprice}</p>
                    <button data-id="${obj.pid}" class="delete-btn">加入购物车</button>
                    </li>`
        })

        let list = document.querySelector('.productlist');
        list.innerHTML = html;

    })
}

loadData()

// 发布商品

//  function publishProduct() {
//         let ipts = document.querySelectorAll('#send input')
//         ipts[4].onclick = function () {
//             let pname = ipts[0].value
//             let pprice = ipts[1].value
//             let pimg = ipts[2].value
//             let pdesc = ipts[3].value
//             let uid = localStorage.getItem('uid')

//             let pAPI = 'http://jx.xuzhixiang.top/ap/api/goods/goods-add.php'
//             axios.get(pAPI, { params: { pname, pprice, pimg, pdesc, uid } })
//                 .then(res => {
//                     console.log(res.data);                  
//                 })
//         }
//     }
  
//     publishProduct()

